[Core] Explicitly Support gzip & deflate for Encodings in Aiohttp - #48388
[Core] Explicitly Support gzip & deflate for Encodings in Aiohttp#48388kashifkhan wants to merge 9 commits into
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 7 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Restricts AioHttpTransport to supported response encodings, preventing decoding failures when optional aiohttp codecs are installed.
Changes:
- Defaults
Accept-Encodingtogzip, deflatewhile preserving caller overrides. - Relocates the aiohttp-specific body helper.
- Adds tests and updates package metadata.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
azure/core/pipeline/transport/_aiohttp.py |
Sets supported encodings and hosts the body helper. |
azure/core/rest/_aiohttp.py |
Imports the relocated helper. |
azure/core/utils/_pipeline_transport_rest_shared.py |
Removes aiohttp-specific logic. |
tests/async_tests/test_universal_http_async.py |
Tests defaults and caller overrides. |
CHANGELOG.md |
Documents the fix. |
azure/core/_version.py |
Bumps the version to 1.42.0. |
This comment has been minimized.
This comment has been minimized.
a9f7bcf to
2d688d8
Compare
This comment has been minimized.
This comment has been minimized.
6b923f3 to
c0dfaf1
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (1)
sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py:345
- A preconfigured
ClientSessioncan supply its own defaultAccept-Encoding(for example,identityor an encoding supported by its custom decompressor). aiohttp gives these per-request headers precedence over session defaults, so this unconditional request default silently replaces that user configuration. Check the session headers before adding the transport fallback, and add coverage for an injected session with a custom default header.
request.headers.setdefault("Accept-Encoding", _SUPPORTED_ACCEPT_ENCODING)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (1)
sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py:191
- This only constrains sessions created by the transport. An injected
aiohttp.ClientSession(auto_decompress=False)with no explicitAccept-Encodingstill falls back toClientRequest.DEFAULT_HEADERS, so environments with Brotli/Zstandard installed can continue advertisingbr/zstd;send()then selects azure-core's gzip/deflate-only manual decompression and the original decode failure remains. Whenauto_decompressis false, set the supported header at request time only if neither the request nor the injected session supplies one, and add coverage for that injected-session case.
"headers": {"Accept-Encoding": _SUPPORTED_ACCEPT_ENCODING},
[Pilot] PR Pipeline Failure AnalysisA CI pipeline failed on this pull request. Here is an automated analysis of what went wrong and how to get the build green. What failedThree distinct failure groups were detected:
Recommended next steps
Raw pipeline analysis (azsdk ci analyze)
|
This PR addresses an issue with
aiohttpandcore. Todayaiohttpautomatically appendsbr(Brotli) andzstdto theAccept-Encodingrequest header when it detects the corresponding optional library (e.g. brotli / brotlicffi ) installed in the environment.When the service honors that and returns a Brotli-encoded response,
azure-corecan't decode it: the aiohttp transport runs withauto_decompress=Falseand decompresses manually, supporting onlygzip / deflate, so the raw bytes reachresponse.text()and raise aUnicodeDecodeErrorRequest does similar, but lets
requests/urllib3decompress the response itself, so it decodes whatever it advertisedWe do the following:
gzipanddeflateforaiohttp